package 动态规划.吃红薯;

import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int T=sc.nextInt();
        for (int i = 0; i < T; i++)
        {
            int n=sc.nextInt();
            int m=sc.nextInt();
            int[] arr=new int[n];
            for (int j = 0; j < n; j++)
            {
                arr[j]=sc.nextInt();
            }
            Arrays.sort(arr);
            int temp=0;
            int max=0;
            if (arr.length==1)
            {
                if (arr[0]>m)
                    System.out.println(0);
                else
                    System.out.println(1);
            }
            else
            {
                for (int j = 0; j < arr.length; j++)
                {
                    if (temp>m)
                    {
                        temp-=arr[j-1];
                        max--;
                        break;
                    }
                    else
                    {
                        temp+=arr[j];
                        max++;
                    }
                }
                System.out.println(max);
            }

        }
    }
}
